<body class="login-layout light-login">
<div class="main-container">
    <div class="main-content">
        <div class="row">
            <div class="col-sm-10 col-sm-offset-1">
                <div class="login-container">
                    <div class="center">
                        <h1>
                            <i class="ace-icon fa fa-leaf green"></i>
                            <span class="grey" id="id-text2">胖洋葱自己的博客</span>
                        </h1>
                    </div>

                    <div class="space-6"></div>

                    <div class="position-relative">
                        <div id="login-box" class="login-box visible widget-box no-border">
                            <div class="widget-body">
                                <div class="widget-main">
                                    <h4 class="header blue lighter bigger">
                                        <i class="ace-icon fa fa-coffee green"></i>
                                        请输入登录信息
                                    </h4>

                                    <div class="space-6"></div>

                                    <form id="login-form" action="#" method="post" onsubmit="javascript:return login();">
                                        <input type="hidden" name="_csrf" value="ZEF4STJ1UkguGDQ4YAw7Ay8JDgBYISsqSTczIGoMZQABcksdBUFmDQ==" />
                                        <fieldset>
                                            <label class="block clearfix">
														<span class="block input-icon input-icon-right">
															<input type="text" class="form-control" placeholder="Username" name="username"/>
															<i class="ace-icon fa fa-user"></i>
														</span>
                                            </label>

                                            <label class="block clearfix">
														<span class="block input-icon input-icon-right">
															<input type="password" class="form-control" placeholder="Password" name="password"/>
															<i class="ace-icon fa fa-lock"></i>
														</span>
                                            </label>

                                            <div class="space"></div>

                                            <div class="clearfix">
                                                <label class="inline">
                                                    <!--															<input type="checkbox" class="ace" />-->
                                                    <!--															<span class="lbl"> Remember Me</span>-->
                                                            <span class="red">
                                                                                                                            </span>
                                                </label>
                                                <a href="/?r=index/password-findback" target="_blank">忘记密码？点此找回</a>
                                                <input id="submit-button" type="submit" class="width-35 pull-right btn btn-sm btn-primary" value="Login">

                                                <!--
                                                <button id="submit-button" type="button" class="width-35 pull-right btn btn-sm btn-primary">
                                                    <i class="ace-icon fa fa-key"></i>
                                                    <span class="bigger-110">Login</span>
                                                </button>
                                                -->
                                            </div>

                                            <div class="space-4"></div>
                                        </fieldset>
                                    </form>

                                </div><!-- /.widget-main -->

                            </div><!-- /.widget-body -->
                        </div><!-- /.login-box -->
                    </div><!-- /.position-relative -->
                </div>
            </div><!-- /.col -->
        </div><!-- /.row -->
    </div><!-- /.main-content -->
</div><!-- /.main-container -->

<script>
    var ajaxUrl = "/login/ajax";
    function login() {
        var username = $("input[name=username]").val();
        var pass = $("input[name=password]").val();

        if (username.length <= 0) {
            alert("用户名不能为空!");
            return false;
        }

        if (pass.length <= 0) {
            alert("密码不能为空!");
            return false;
        }
        var pass_md5 = hex_md5(pass);

        var postData = {
            action    : "login_admin",
            username  : username,
            password  : pass_md5
        };

        $.ajax({
            type : "POST",
            url  : ajaxUrl,
            data : postData,
            dataType : "json",
            success : function(res) {
                if (res.status == 200) {
                    window.location.href="<?=$from?>";
                } else {
                    alert(res.msg);
                }
            }
        });

        return false;
    }
</script>